//
//  WheelButton.m
//  12-转盘(了解)
//
//  Created by J on 16/3/23.
//  Copyright © 2016年 J. All rights reserved.
//

#import "WheelButton.h"

@implementation WheelButton

//设置内部imageView
- (CGRect)imageRectForContentRect:(CGRect)contentRect{//让按钮内部的图片尺寸变小
    
    CGSize size = contentRect.size;
    
    return CGRectMake(size.width*0.25, 20, size.width*0.4, size.height*0.4);
}


- (void)setHighlighted:(BOOL)highlighted{
    
}

//寻找最合适的View
-(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event{
    
    CGFloat btnW = self.bounds.size.width;
    CGFloat btnH = self.bounds.size.height;
    
    
    
    CGFloat x = 0;
    CGFloat y = btnH/2.0;
    CGFloat w = btnW;
    CGFloat h = y;
    
    CGRect rect = CGRectMake(x, y,w, h);
   BOOL isIn =  CGRectContainsPoint(rect, point);//如果在按钮的下部分不允许点击
    if (isIn) {
        return nil;
    }else{//只能点击上部分 
        return [super hitTest:point withEvent:event];
    }
    
}
@end
